class_name 精灵Operation extends Node

var operationManager:OperationManager
var big:Big

func init(om:OperationManager):
	self.operationManager = om
	return self


func preparation_精灵_move():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	var arr = Array()
	var arrAroundPoints = GameUtils.getArrPointsAround(point)
	var arrShaPoints = GameUtils.getArrPointsSha()
	arr.append_array(arrAroundPoints)
	arr.append_array(arrShaPoints)
	for p in arr:
		if p.is_view:
			if [Terrain.shan,Terrain.shui,Terrain.jing].has(p.real_terrain):
				continue
			if p.small != null:
				continue
			if p.big != null:		#有大子
				if p.big.player.is_me:	#是自己的
					continue
				if !p.big.arr_states.has(BigStateType.HIDE):	#敌人大子没有潜行
					continue
		operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big = point.big
	big.detailHide()


func preparation_精灵_赐福():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	var arrAroundPoints = GameUtils.getArrPointsAround(point)
	for p in arrAroundPoints:
		if p.big != null:
			if p.big.player.is_me:
				if p.big.evolution == "未转型":
					operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big = point.big
	big.detailHide()


func preparation_精灵_庇护():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	var arrAroundPoints = GameUtils.getArrPointsAround(point)
	for p in arrAroundPoints:
		if p.big != null:
			if p.big.player.is_me:
				if p.big.evolution == "未转型":
					operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big = point.big
	big.detailHide()

func 精灵_move(point:Point):
	WebSocketManager.sendObj(true,"精灵_move",{"start":big.point.id,"end":point.id})
	operationManager.cancel()

func 精灵_赐福(point:Point):
	WebSocketManager.sendObj(true,"精灵_赐福",{"start":big.point.id,"end":point.id})
	operationManager.cancel()


func 精灵_庇护(point:Point):
	WebSocketManager.sendObj(true,"精灵_庇护",{"start":big.point.id,"end":point.id})
	operationManager.cancel()
